# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=authoscope
pkgver=0.8.1
pkgrel=2
pkgdesc='Scriptable network authentication cracker'
url='https://github.com/kpcyrd/authoscope'
depends=('openssl' 'lua52' 'libcap' 'zlib')
makedepends=('cargo')
arch=('loong64' 'x86_64')
license=('GPL3')
install=authoscope.install
provides=('badtouch')
conflicts=('badtouch')
replaces=('badtouch')
source=(https://github.com/kpcyrd/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc)
sha512sums=('98c73346584860badf9fa18f98900419d0cf8b391c651cf864c325ab302281f8a3186038acc4e7bc8d2bb35dc948f2f524120a13aff7883b7938d9a96de08b08'
            'SKIP')
b2sums=('9a22267b8d3620a0a5d0867e9f6214673730fdd405c2fb4b3562a9fbea9b571a9a8c02a3be5074b72a5dfeaf7d8d2b3a42877c6b9a24d531e7c389ad56e83688'
        'SKIP')
validpgpkeys=('64B13F7117D6E07D661BBCE0FE763A64F5E54FD6')

build() {
  cd ${pkgname}-${pkgver}
  cargo build --release --locked
}

check() {
  cd ${pkgname}-${pkgver}
  cargo test --release --locked
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 target/release/${pkgname} \
    target/release/badtouch \
    -t "${pkgdir}/usr/bin"

  install -d "${pkgdir}/usr/share/bash-completion/completions" \
             "${pkgdir}/usr/share/zsh/site-functions" \
             "${pkgdir}/usr/share/fish/vendor_completions.d"
  "${pkgdir}/usr/bin/authoscope" completions bash > "${pkgdir}/usr/share/bash-completion/completions/authoscope"
  "${pkgdir}/usr/bin/authoscope" completions zsh > "${pkgdir}/usr/share/zsh/site-functions/_authoscope"
  "${pkgdir}/usr/bin/authoscope" completions fish > "${pkgdir}/usr/share/fish/vendor_completions.d/authoscope.fish"

  install -Dm 644 docs/authoscope.1 -t "${pkgdir}/usr/share/man/man1"
  install -Dm 644 scripts/* -t "${pkgdir}/usr/share/doc/${pkgname}/examples"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
